home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / mpw-configure < prev    next >
Encoding:
Text File  |  1996-07-15  |  12.3 KB  |  391 lines

  1. # Configuration script
  2. # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
  3.  
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15.  
  16. ### WARNING
  17. ### This script must NOT use any 8-bit chars!
  18. ### WARNING
  19.  
  20. # This is an MPW Shell script that sets everything up for compilation,
  21. # mainly creating directories, and editing copies of files.
  22.  
  23. Set savedir "`Directory`"
  24.  
  25. #Set Echo 1
  26.  
  27. Set ThisScript "{0}"
  28.  
  29. Set srcroot "--------"
  30.  
  31. Set srcdir ":"
  32.  
  33. Set objdir ":"
  34.  
  35. Set prefix "{MPW}":GNUTools:
  36.  
  37. Set exec_prefix ""
  38.  
  39. Set bindir ""
  40.  
  41. Set host_alias "m68k-apple-mpw"
  42.  
  43. Set target_alias {host_alias}
  44.  
  45. Set host_cc "mpwc"
  46.  
  47. Set with_gnu_ld 0
  48.  
  49. Set verify 0
  50. Set verifystr ""
  51.  
  52. # Parse arguments.
  53.  
  54. Loop
  55.     Break If {#} == 0
  56.     If "{1}" =~ /--cc/
  57.         Set host_cc "{2}"
  58.         Shift 1
  59.     Else If "{1}" =~ /--bindir/
  60.         Set bindir "{2}"
  61.         Shift 1
  62.     Else If "{1}" =~ /--disable-?+/
  63.         Set "`Echo {1} | sed -e 's/--disable-/enable_/'`" no
  64.     Else If "{1}" =~ /--enable-?+/
  65.         Set "`Echo {1} | sed -e 's/--enable-/enable_/'`" yes
  66.     Else If "{1}" =~ /--exec-prefix/
  67.         Set exec_prefix "{2}"
  68.         Shift 1
  69.     Else If "{1}" =~ /--host/
  70.         Set host_alias "{2}"
  71.         Shift 1
  72.     Else If "{1}" =~ /--prefix/
  73.         Set prefix "{2}"
  74.         Shift 1
  75.     Else If "{1}" =~ /--srcdir/
  76.         Set srcdir "{2}"
  77.         Shift 1
  78.     Else If "{1}" =~ /--srcroot/
  79.         Set srcroot "{2}"
  80.         Shift 1
  81.     Else If "{1}" =~ /--target/
  82.         Set target_alias "{2}"
  83.         Shift 1
  84.     Else If "{1}" =~ /-v/
  85.         Set verify 1
  86.         Set verifystr "-v"
  87.     Else If "{1}" =~ /--with-gnu-ld/
  88.         Set with_gnu_ld 1
  89.     Else
  90.         Echo "{1}" is not a valid argument
  91.         Exit 1
  92.     End If
  93.     Shift 1
  94. End Loop
  95.  
  96. Set Exit 0
  97.  
  98. # Default exec_prefix from prefix.
  99.  
  100. If "{exec_prefix}" == ""
  101.     Set exec_prefix "{prefix}"
  102. End If
  103.  
  104. If "{bindir}" == ""
  105.     Set bindir "{prefix}"bin:
  106. End If
  107.  
  108. # Point to the correct set of tools to use with the chosen compiler.
  109.  
  110. If "{host_cc}" =~ /mpwc/
  111.     Set host_alias "m68k-apple-mpw"
  112.     Set cc_name '{CC_MPW_C}'
  113.     Set segment_flag '-s {Default}'
  114.     Set ar_name '{AR_LIB}'
  115.     Set ranlib_name '{RANLIB_NULL}'
  116.     Set cc_ld_name '{CC_LD_LINK}'
  117.     Set prog_ext_name '{PROG_EXT_68K}'
  118.     Set extralibs_name '{EXTRALIBS_C}'
  119.     Set makepef_name '{MAKEPEF_NULL}'
  120.     Set rez_name '{REZ_68K}'
  121. Else If "{host_cc}" =~ /sc68k/
  122.     Set host_alias "m68k-apple-mpw"
  123.     Set cc_name '{CC_SC}'
  124.     Set segment_flag '-s {Default}'
  125.     Set ar_name '{AR_LIB}'
  126.     Set ranlib_name '{RANLIB_NULL}'
  127.     Set cc_ld_name '{CC_LD_LINK}'
  128.     Set prog_ext_name '{PROG_EXT_68K}'
  129.     Set extralibs_name '{EXTRALIBS_C}'
  130.     Set makepef_name '{MAKEPEF_NULL}'
  131.     Set rez_name '{REZ_68K}'
  132. Else If "{host_cc}" =~ /mwc68k/
  133.     Set host_alias "m68k-apple-mpw"
  134.     Set cc_name '{CC_MWC68K}'
  135.     Set segment_flag '-s {Default}'
  136.     Set ar_name '{AR_MWLINK68K}'
  137.     Set ranlib_name '{RANLIB_NULL}'
  138.     Set cc_ld_name '{CC_LD_MWLINK68K}'
  139.     Set prog_ext_name '{PROG_EXT_68K}'
  140.     Set extralibs_name '{EXTRALIBS_MWC68K}'
  141.     Set makepef_name '{MAKEPEF_NULL}'
  142.     Set rez_name '{REZ_68K}'
  143. Else If "{host_cc}" =~ /gcc68k/
  144.     Set host_alias "m68k-apple-mpw"
  145.     Set cc_name '{CC_68K_GCC}'
  146.     Set segment_flag '-s {Default}'
  147.     Set ar_name '{AR_68K_AR}'
  148.     Set ranlib_name '{RANLIB_RANLIB}'
  149.     Set cc_ld_name '{CC_68K_GCC}'
  150.     Set prog_ext_name '{PROG_EXT_68K}'
  151.     Set extralibs_name '{EXTRALIBS_C}'
  152.     Set makepef_name '{MAKEPEF_NULL}'
  153.     Set rez_name '{REZ_68K}'
  154. Else If "{host_cc}" =~ /ppcc/
  155.     Set host_alias "powerpc-apple-mpw"
  156.     Set cc_name '{CC_PPCC}'
  157.     Set segment_flag ''
  158.     Set ar_name '{AR_PPCLINK}'
  159.     Set ranlib_name '{RANLIB_NULL}'
  160.     Set cc_ld_name '{CC_LD_PPCLINK}'
  161.     Set prog_ext_name '{PROG_EXT_XCOFF}'
  162.     Set extralibs_name '{EXTRALIBS_PPC}'
  163.     Set makepef_name '{MAKEPEF_PPC}'
  164.     Set rez_name '{REZ_PPC}'
  165. Else If "{host_cc}" =~ /mrc/
  166.     Set host_alias "powerpc-apple-mpw"
  167.     Set cc_name '{CC_MRC}'
  168.     Set segment_flag ''
  169.     Set ar_name '{AR_PPCLINK}'
  170.     Set ranlib_name '{RANLIB_NULL}'
  171.     Set cc_ld_name '{CC_LD_PPCLINK}'
  172.     Set prog_ext_name '{PROG_EXT_XCOFF}'
  173.     Set extralibs_name '{EXTRALIBS_PPC}'
  174.     Set makepef_name '{MAKEPEF_PPC}'
  175.     Set rez_name '{REZ_PPC}'
  176. Else If "{host_cc}" =~ /scppc/
  177.     Set host_alias "powerpc-apple-mpw"
  178.     Set cc_name '{CC_SC}'
  179.     Set segment_flag ''
  180.     Set ar_name '{AR_PPCLINK}'
  181.     Set ranlib_name '{RANLIB_NULL}'
  182.     Set cc_ld_name '{CC_LD_PPCLINK}'
  183.     Set prog_ext_name '{PROG_EXT_XCOFF}'
  184.     Set extralibs_name '{EXTRALIBS_PPC}'
  185.     Set makepef_name '{MAKEPEF_PPC}'
  186.     Set rez_name '{REZ_PPC}'
  187. Else If "{host_cc}" =~ /mwcppc/
  188.     Set host_alias "powerpc-apple-mpw"
  189.     Set cc_name '{CC_MWCPPC}'
  190.     Set segment_flag ''
  191.     Set ar_name '{AR_MWLINKPPC}'
  192.     Set ranlib_name '{RANLIB_NULL}'
  193.     Set cc_ld_name '{CC_LD_MWLINKPPC}'
  194.     # Misleading, but we don't need a PEF step.
  195.     Set prog_ext_name '{PROG_EXT_68K}'
  196.     Set extralibs_name '{EXTRALIBS_MWCPPC}'
  197.     Set makepef_name '{MAKEPEF_NULL}'
  198.     Set rez_name '{REZ_PPC}'
  199. Else If "{host_cc}" =~ /gccppc/
  200.     Set host_alias "powerpc-apple-mpw"
  201.     Set cc_name '{CC_PPC_GCC}'
  202.     Set segment_flag ''
  203.     Set ar_name '{AR_PPCLINK}'
  204.     Set ranlib_name '{RANLIB_RANLIB}'
  205.     If {with_gnu_ld} == 1
  206.         Set cc_ld_name '{CC_LD_GLD}'
  207.     Else
  208.         Set cc_ld_name '{CC_LD_PPCLINK}'
  209.     End If
  210.     Set prog_ext_name '{PROG_EXT_XCOFF}'
  211.     Set extralibs_name '{EXTRALIBS_PPC}'
  212.     Set makepef_name '{MAKEPEF_PPC}'
  213.     Set rez_name '{REZ_PPC}'
  214. Else
  215.     Echo "{host_cc}" is not a known MPW compiler type
  216. End If
  217.  
  218. # (should interpret aliases if not in canonical form)
  219.  
  220. Set host_canonical "{host_alias}"
  221.  
  222. Set target_canonical "{target_alias}"
  223.  
  224. Set configdirs ""
  225.  
  226. If "{srcroot}" =~ /--------/
  227.     Set srcroot "{srcdir}"
  228. End If
  229. If "`Exists "{srcdir}"`" == ""
  230.     Echo Source directory {srcdir} does not exist!
  231.     Exit 1
  232. End If
  233. If "`Exists "{srcroot}"`" == ""
  234.     Echo Top-level source directory {srcroot} does not exist!
  235.     Exit 1
  236. End If
  237.  
  238. Set target_cpu "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`"
  239. Set target_vendor "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`"
  240. Set target_os "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`"
  241.  
  242. # Create a file that is guaranteed to be older than any other here.
  243.  
  244. If "`Exists "{objdir}"_oldest`" == ""
  245.     mpw-touch _oldest
  246. End If
  247.  
  248. # Record this before creating any files, makefiles sometimes mention
  249. # dependencies on config.status.
  250.  
  251. Echo "# This directory was configured as follows:" >config.new
  252. Echo "{ThisScript} --host {host_alias} --target {target_alias} --srcdir {srcdir}  --srcroot {srcroot}  --prefix {prefix} --cc {host_cc}" >>config.new
  253. MoveIfChange config.new config.status
  254.  
  255. If "`Exists "{srcdir}"mpw-config.in`" != ""
  256.     tr-7to8 "{srcdir}"mpw-config.in >"{objdir}"mpw-config.in
  257.     Execute "{objdir}"mpw-config.in
  258. End If
  259.  
  260. # Start Makefile construction by defining all the variables chosen by
  261. # configuration.
  262.  
  263. Echo "# This Makefile produced by mpw-configure.  Changes may get lost!" > "{objdir}"Makefile.tem
  264. Echo "srcroot = " {srcroot}            >> "{objdir}"Makefile.tem
  265. Echo "topsrcdir = " {srcroot}            >> "{objdir}"Makefile.tem
  266. Echo "srcdir = " {srcdir}            >> "{objdir}"Makefile.tem
  267. Echo "mpw_prefix = " {prefix}            >> "{objdir}"Makefile.tem
  268. Echo "mpw_exec_prefix = " {exec_prefix}        >> "{objdir}"Makefile.tem
  269. Echo "mpw_bindir = " {bindir}            >> "{objdir}"Makefile.tem
  270. Echo "host_alias = " {host_alias}        >> "{objdir}"Makefile.tem
  271. Echo "target_alias = " {target_alias}        >> "{objdir}"Makefile.tem
  272. Echo "target_cpu = " {target_cpu}        >> "{objdir}"Makefile.tem
  273. Echo "target_vendor = " {target_vendor}        >> "{objdir}"Makefile.tem
  274. Echo "target_os = " {target_os}            >> "{objdir}"Makefile.tem
  275. Echo "target_canonical = " {target_canonical}    >> "{objdir}"Makefile.tem
  276. Echo "host_makefile_frag = "            >> "{objdir}"Makefile.tem
  277. Echo "target_makefile_frag = "            >> "{objdir}"Makefile.tem
  278. Echo "CC = " {cc_name}                >> "{objdir}"Makefile.tem
  279. Echo "AR = " {ar_name}                >> "{objdir}"Makefile.tem
  280. Echo "RANLIB = " {ranlib_name}            >> "{objdir}"Makefile.tem
  281. Echo "CC_LD = " {cc_ld_name}            >> "{objdir}"Makefile.tem
  282. Echo "PROG_EXT = " {prog_ext_name}        >> "{objdir}"Makefile.tem
  283. Echo "EXTRALIBS = " {extralibs_name}        >> "{objdir}"Makefile.tem
  284. Echo "MAKEPEF = " {makepef_name}        >> "{objdir}"Makefile.tem
  285. Echo "REZ = " {rez_name}            >> "{objdir}"Makefile.tem
  286.  
  287. # Append the master set of definitions for the various compilers.
  288.  
  289. If "`Exists "{srcdir}"config:mpw-mh-mpw`" != ""
  290.     tr-7to8 "{srcdir}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem
  291. Else If "`Exists "{srcroot}"config:mpw-mh-mpw`" != ""
  292.     tr-7to8 "{srcroot}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem
  293. Else
  294.     Echo "can't find a host config file!"
  295.     Exit 0
  296. End If
  297.  
  298. # Append anything produced by the directory's mpw-config.in.
  299.  
  300. If "`Exists "{objdir}"mk.tmp`" != ""
  301.     Catenate "{objdir}"mk.tmp >>"{objdir}"Makefile.tem
  302.     # An mpw-config.in might change so as not to create this
  303.     # anymore, so get rid of it now to be safe.
  304.     Delete -i -y "{objdir}"mk.tmp
  305. End If
  306.  
  307. # If there are sed scripts to edit the Unix Makefile.in, use them; otherwise
  308. # use an mpw-make.in if present.
  309.  
  310. If "`Exists "{srcdir}"mpw-make.sed`" != ""
  311.     If "`Exists "{objdir}"hacked_Makefile.in`" != ""
  312.         Set MakefileIn "{objdir}"hacked_Makefile.in
  313.     Else
  314.         Set MakefileIn "{srcdir}"Makefile.in
  315.     End If
  316.     # Find the generic makefile editing script.
  317.     If "`Exists "{srcroot}"config:mpw:g-mpw-make.sed`" != ""
  318.         sed -f "{srcroot}"config:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1
  319.     Else If "`Exists "{srcroot}"utils:mpw:g-mpw-make.sed`" != ""
  320.         sed -f "{srcroot}"utils:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1
  321.     Else If "`Exists "{srcdir}"g-mpw-make.sed`" != ""
  322.         sed -f "{srcdir}"g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1
  323.     Else
  324.         Echo Warning: g-mpw-make.sed not found, copying "{MakefileIn}" verbatim...
  325.         Catenate "{MakefileIn}" >"{objdir}"Makefile.tem1
  326.     End If
  327.     sed -f "{srcdir}"mpw-make.sed "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2
  328.     sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' -e 's/^exec_prefix = .*$/exec_prefix = {mpw_exec_prefix}/g' -e 's/^bindir = @bindir@/bindir = {mpw_bindir}/g' "{objdir}"Makefile.tem2 >"{objdir}"Makefile.tem3
  329.     sed -e "s/@SEGMENT_FLAG@/{segment_flag}/" "{objdir}"Makefile.tem3 >"{objdir}"mpw-make.in
  330.     tr-7to8 "{objdir}"mpw-make.in >>"{objdir}"Makefile.tem
  331.     If "`Exists "{objdir}"mk.sed`" != ""
  332.         sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2
  333.         Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem
  334.     End If
  335.     MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile
  336.     Delete -i -y "{objdir}"Makefile.tem[12]
  337.     If {verify} == 1
  338.         Echo Created Makefile in "`Directory`"
  339.     End If
  340. Else If "`Exists "{srcdir}"mpw-make.in`" != ""
  341.     sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' "{srcdir}"mpw-make.in >"{objdir}"Makefile.tem1
  342.     sed -e "s/@SEGMENT_FLAG@/{segment_flag}/" "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2
  343.     tr-7to8 "{objdir}"Makefile.tem2 >>"{objdir}"Makefile.tem
  344.     If "`Exists "{objdir}"mk.sed`" != ""
  345.         sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2
  346.         Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem
  347.     End If
  348.     MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile
  349.     Delete -i -y "{objdir}"Makefile.tem[12]
  350.     If {verify} == 1
  351.         Echo Created Makefile in "`Directory`"
  352.     End If
  353. End If
  354.  
  355. # Produce a build script if the source is defined.
  356.  
  357. If "`Exists "{srcdir}"mpw-build.in`" != ""
  358.     Echo "Set srcroot " {srcroot} > "{objdir}"mpw-build.tem
  359.     Echo "Set srcdir " {srcdir} >> "{objdir}"mpw-build.tem
  360.     Echo "Set target_canonical " {target_canonical} >> "{objdir}"mpw-build.tem
  361.     Echo "Set prefix " {prefix} >> "{objdir}"mpw-build.tem
  362.     tr-7to8 "{srcdir}"mpw-build.in >>"{objdir}"mpw-build.tem
  363.     MoveIfChange "{objdir}"mpw-build.tem "{objdir}"mpw-build
  364.     If {verify} == 1
  365.         Echo Created mpw-build in "`Directory`"
  366.     End If
  367. End If
  368.  
  369. # Apply ourselves recursively to the list of subdirectories to configure.
  370.  
  371. For subdir In {configdirs}
  372.     Set savedir "`Directory`"
  373.     If "`Exists "{srcdir}{subdir}:"`" == ""
  374.         Echo Strange, no {subdir} in {srcdir}
  375.         Continue
  376.     End If
  377.     If {verify} == 1
  378.         Echo Configuring {subdir}...
  379.     End If
  380.     If "`Exists "{objdir}{subdir}:"`" == ""
  381.         NewFolder "{objdir}{subdir}"
  382.     End If
  383.     SetDirectory "{objdir}{subdir}:"
  384.     "{ThisScript}" --target "{target_canonical}" --srcdir "{srcdir}{subdir}:" --srcroot "{srcroot}" --prefix "{prefix}" --cc "{host_cc}" {verifystr}
  385.     SetDirectory "{savedir}"
  386. End For
  387.  
  388. SetDirectory "{savedir}"
  389.